#include <iostream>
using namespace std;


void slove()
{
    int h,a,H,A;
    cin >> h >> a >> H >> A;
    if(a >= H)
    {
        cout << -1 << endl;
        return;
    }
    int t = H / a + (H % a == 0 ? 0 : 1);
    int sum = (t - 1) * A;
    cout << h / sum - (h % sum == 0 ? 1 : 0) << endl;
}

int main() {
    int n;
    cin >> n;
    while(n--)
    {
        slove();
    }
    return 0;
}
// 64 位输出请用 printf("%lld")